package com.zxy.zxyrpc.server;

import com.zxy.zxyrpc.serializer.Serializer;
import com.zxy.zxyrpc.spi.SpiLoader;

/**
 * 协议工厂
 *
 * @author zxy
 * @since 2025/5/13
 **/
public class VertxServerFactory {
    /**
     * 私有化构造器，采用懒汉式单例创建
     * */
    private static volatile VertxServerFactory serializerFactory;
    private VertxServerFactory(){}

    /*static {
        SpiLoader.load(VertxServer.class);
    }*/

    /**
     * 根据参数获取序列化器实例
     * 扩展：懒汉式创建工厂实例
     */
    public static VertxServer getInstance(String key) {
        if (serializerFactory == null){
            synchronized (VertxServerFactory.class){
                if (serializerFactory == null)
                    serializerFactory = new VertxServerFactory();
            }
        }
        return SpiLoader.getInstance(VertxServer.class, key);
    }
}
